#pragma once

#include "WolvGen.h"
#include "Expression.h"
#include "Variable.h"

MAKE_PTR(CExpression_Assign);

class CExpression_Assign : public CExpression
{
public:
	static CExpression_AssignPtr create(CVariablePtr var, CExpressionPtr exp)
	{
		return CExpression_AssignPtr(new CExpression_Assign(var, exp));
	}

public:
	CExpression_Assign(CVariablePtr var, CExpressionPtr exp)
		:m_pVar(var), m_pExp(exp)
	{

	}

protected:
	CVariablePtr m_pVar;
	CExpressionPtr m_pExp;

public:
	int doEval()
	{
		EvalType result = m_pExp->eval();
		m_pVar->setValue(result);
		return result;
	};
};